package com.cagtwitter.servlet;

import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;

import org.quartz.JobDetail;
import org.quartz.Scheduler;
import org.quartz.SchedulerException;
import org.quartz.SchedulerFactory;
import org.quartz.SimpleTrigger;
import org.quartz.impl.StdSchedulerFactory;
import com.cagtwitter.scheduledJobs.DBRefresh;

public class ScheduledJobs extends HttpServlet {
	public void init() throws ServletException{
		SchedulerFactory sf=new StdSchedulerFactory();
		Scheduler sched;
		try {
			sched = sf.getScheduler();
			
			JobDetail jd=new JobDetail("myjob",Scheduler.DEFAULT_GROUP,DBRefresh.class);
			SimpleTrigger st=new SimpleTrigger("mytrigger",Scheduler.DEFAULT_GROUP);
			
			st.setRepeatInterval(15 * 60 * 1000); //min
			st.setRepeatCount(-1);
			sched.scheduleJob(jd, st);
			sched.start();
			
			
		} catch (SchedulerException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		}
		

	}
}
